package io.github.maojian.dynamicprogramming;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022/6/11 11:16
 * @Description: https://leetcode.cn/problems/flip-string-to-monotone-increasing/
 */
public class Q926 {
    public int minFlipsMonoIncr(String s) {
        int dp = 0, cnt = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (s.charAt(i) == '1') {
                ++cnt;
            } else {
                dp = Math.min(dp + 1, cnt);
            }
        }
        return dp;
    }

    @Test
    public void test() {
        String s = "00011000";
        System.out.println(minFlipsMonoIncr(s));
    }
}
